<?php
/**
 * @version     1.0.4
 * @package     com_hotels
 * @copyright   Copyright (C) 2014. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 * @author      Russell English <russell.english@stormit.co.uk> - http://www.stormit.co.uk
 */
// no direct access
defined('_JEXEC') or die;

JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('behavior.keepalive');

// Import CSS
$document = JFactory::getDocument();
$document->addStyleSheet('components/com_hotels/assets/css/hotels.css');
?>
<script type="text/javascript">
    js = jQuery.noConflict();
    js(document).ready(function() {
        
    });

    Joomla.submitbutton = function(task)
    {
        if (task == 'availability.cancel') {
            Joomla.submitform(task, document.getElementById('availability-form'));
        }
        else {
            
            if (task != 'availability.cancel' && document.formvalidator.isValid(document.id('availability-form'))) {
                
                Joomla.submitform(task, document.getElementById('availability-form'));
            }
            else {
                alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED')); ?>');
            }
        }
    }
</script>

<form action="<?php echo JRoute::_('index.php?option=com_hotels&layout=edit&id=' . (int) $this->item->id); ?>" method="post" enctype="multipart/form-data" name="adminForm" id="availability-form" class="form-validate">

    <div class="form-horizontal">
        <?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'general')); ?>

        <?php echo JHtml::_('bootstrap.addTab', 'myTab', 'general', JText::_('COM_HOTELS_TITLE_AVAILABILITY', true)); ?>
        <div class="row-fluid">
            <div class="span10 form-horizontal">
                <fieldset class="adminform">

                    			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('mykey'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('mykey'); ?></div>
			</div>
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('hotelcode'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('hotelcode'); ?></div>
			</div>
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('stgcode'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('stgcode'); ?></div>
			</div>
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('hotelname'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('hotelname'); ?></div>
			</div>
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('resortcode'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('resortcode'); ?></div>
			</div>
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('resortname'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('resortname'); ?></div>
			</div>
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('dep'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('dep'); ?></div>
			</div>
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('arr'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('arr'); ?></div>
			</div>
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('startdate'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('startdate'); ?></div>
			</div>
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('enddate'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('enddate'); ?></div>
			</div>
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('brochureprice'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('brochureprice'); ?></div>
			</div>
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('discount'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('discount'); ?></div>
			</div>
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('sellingprice'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('sellingprice'); ?></div>
			</div>
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('seats'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('seats'); ?></div>
			</div>
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('rooms'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('rooms'); ?></div>
			</div>
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('beds'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('beds'); ?></div>
			</div>
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('available'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('available'); ?></div>
			</div>
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('entry'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('entry'); ?></div>
			</div>
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('active'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('active'); ?></div>
			</div>
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('originalprice'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('originalprice'); ?></div>
			</div>
				<input type="hidden" name="jform[id]" value="<?php echo $this->item->id; ?>" />
			<div class="control-group">
				<div class="control-label"><?php echo $this->form->getLabel('state'); ?></div>
				<div class="controls"><?php echo $this->form->getInput('state'); ?></div>
			</div>
				<input type="hidden" name="jform[checked_out]" value="<?php echo $this->item->checked_out; ?>" />
				<input type="hidden" name="jform[checked_out_time]" value="<?php echo $this->item->checked_out_time; ?>" />

				<?php if(empty($this->item->created_by)){ ?>
					<input type="hidden" name="jform[created_by]" value="<?php echo JFactory::getUser()->id; ?>" />

				<?php } 
				else{ ?>
					<input type="hidden" name="jform[created_by]" value="<?php echo $this->item->created_by; ?>" />

				<?php } ?>

                </fieldset>
            </div>
        </div>
        <?php echo JHtml::_('bootstrap.endTab'); ?>
        
        

        <?php echo JHtml::_('bootstrap.endTabSet'); ?>

        <input type="hidden" name="task" value="" />
        <?php echo JHtml::_('form.token'); ?>

    </div>
</form>